//app.js
import {
  hsetStorage,
  hgetStorage,
  hnavigateTo
} from '/static/htools.wx'
App({
  onLaunch() {
    //判断是否登录
    wx.getSetting({
      success:(res)=>{
        if(!res.authSetting['scope.userInfo']){
          hsetStorage('isAuthor',0)
        }else{
          if(hgetStorage('token')){
            hsetStorage('isAuthor',1)
          }else{
            hsetStorage('isAuthor',2)
          }
        }
      }
    })
    //自定义导航 适配
    let menuButtonObject = wx.getMenuButtonBoundingClientRect();
    wx.getSystemInfo({
      success: res => {
        //导航高度
        let statusBarHeight = res.statusBarHeight,
          navTop = menuButtonObject.top,
          navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight)*2;
        this.globalData.navHeight = navHeight;
        this.globalData.navTop = navTop;
        this.globalData.windowHeight = res.windowHeight;
      },
      fail(err) {
        console.log(err);
      }
    })
  },
  globalData: {}
})